APP:= run_quantification
APP2:= test_time

TARGET_DEVICE = $(shell gcc -dumpmachine |cut -f1 -d -)


SRCS:=main.cpp 
SRCS+=$(wildcard src/*.cpp)

SRCS2:=test_infer_time.cpp

INCS:=$(wildcard include/*.h)

CFLAGS+=-I/usr/include/aarch64-linux-gnu \
		-I/usr/local/cuda/include \
		-I/usr/include/opencv4 \
		-I include

OBJS:= $(SRCS:.cpp=.o)
OBJS2:=$(SRCS2:.cpp=.o)

COMMON_LIB_DIR:= /usr/lib/aarch64-linux-gnu
LIBS+= -L$(COMMON_LIB_DIR) -lnvinfer -lnvonnxparser -lopencv_core -lopencv_dnn -lopencv_imgproc -lopencv_imgcodecs \
       -Wl,-rpath,$(COMMON_LIB_DIR)

CUDA_LIB_DIR:=/usr/local/cuda/lib64
LIBS+= -L$(CUDA_LIB_DIR) -lcudart -Wl,-rpath,$(CUDA_LIB_DIR)


all: $(APP) $(APP2)

%.o: %.c $(INCS) Makefile
	$(CC) -g -c -o $@ $(CFLAGS) $<

%.o: %.cpp $(INCS) Makefile
	$(CXX) -g -c -o $@ $(CFLAGS) $<

$(APP): $(OBJS) Makefile
	$(CXX) -g -o $(APP) $(OBJS) $(LIBS)

$(APP2): $(OBJS2) Makefile
	$(CXX) -g -o $(APP2) $(OBJS2) $(LIBS)

clean:
	rm -rf $(OBJS) $(APP)
